<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<jsp:include page="/all/base.jsp" />
<html>
<head>
<script type="text/javascript"
	src="${contextPath}/js/field_formatter.js"></script>
<title>角色资源管理</title>

<script type="text/javascript">
    var dataGrid = null;
    var suWindow = null;
	var columns = [[{field: 'id', title: 'ID', hidden: true},
        	    	{field: 'role', title: '角色名称', formatter: roleFormatter, width: 100},
        	    	{field: 'resource', title: '访问权限', formatter: resourceFormatter, width: 100}]];
   	var param = {
   		id: "maingrid",
		url: m_role_res_find_url,
		deleteUrl: m_role_res_delete_url,
		width: 'auto',
		height: 'auto',
		fitColumns: true,
		nowrap:false,
		rownumbers:true,
		columns:columns,
		singleSelect:true,
		onDblClickRow:function(rowIndex, rowData) {
			f_modify();
		},
		onRowsSelectedBindButtons:[{id:'modifyBtn', isEnable:function(rows){
				return rows.length == 1;
			}
		}, {id:'deleteBtn', isEnable:function(rows){
				return rows.length > 0;
			}
		}]
	};
	var windowParm = {
		id:"win",
		width:600,
	    height:400,
	    modal:true,
	    closed:true,
	    minimizable:false,
	    maximizable:false,
	    iconCls:"icon-save",
	    onClose:function() {
	    }
	};
	$(function () {
		dataGrid = new optimus.DataGrid(param);
		suWindow = new optimus.Window(windowParm);
	});

	function f_add() {
		suWindow.open("添加角色_资源", role_res_edit_page);
	}
	
	function f_modify() {
		var item = dataGrid.getSelectedRow();
		var url = role_res_edit_page + "?id=' + item.id;
		suWindow.open("修改角色_资源", url);
	}
	
	function onSubmitChangeSuccess() {
		f_reload();
		suWindow.close();
	}

	function cancelSaveOrUpdate() {
		suWindow.close();
	}

	function f_delete() {
		dataGrid.deleteSelectedRows();
	}

	function f_reload() {
		dataGrid.reload();
	}
</script>
</head>
<body style="padding: 10px">
<div style="margin-bottom:20px;">
<a href="#" id="addBtn" class="easyui-linkbutton" onclick="f_add()">添加</a>
<a href="#" id="modifyBtn" class="easyui-linkbutton" onclick="f_modify()">修改</a>
<a href="#" id="deleteBtn" class="easyui-linkbutton" onclick="f_delete()">删除</a>
<a href="#" id="reloadBtn" class="easyui-linkbutton" onclick="f_reload()">刷新</a>
</div>
<div id="maingrid" style="margin-top: 20px"></div>
<div id="win"></div>
</body>
</html>